package com.cloudbroker.bcs.platform.ltb.middle.extservice.itn.token;

import java.io.Serializable;
import java.util.Date;

public class ITNToken implements Serializable {
	private static final long serialVersionUID = 2396685940485675989L;
	private String token_type;
	private String access_token;
	private String expires_in;
	private String refresh_token;
	private Date create_time;
	private String scope;

	public boolean expires() {
		Date nowTime = new Date();
		double spendTime = (nowTime.getTime() - create_time.getTime()) / (double)1000;
		double remainTime = Integer.parseInt(expires_in) - spendTime;	//剩余时间 (s)
		return remainTime < 30;
	}

	public String getToken_type() {
		return token_type;
	}

	public void setToken_type(String token_type) {
		this.token_type = token_type;
	}

	public String getAccess_token() {
		return access_token;
	}

	public void setAccess_token(String access_token) {
		this.access_token = access_token;
	}

	public String getExpires_in() {
		return expires_in;
	}

	public void setExpires_in(String expires_in) {
		this.expires_in = expires_in;
		this.expires_in = "90";
	}

	public String getRefresh_token() {
		return refresh_token;
	}

	public void setRefresh_token(String refresh_token) {
		this.refresh_token = refresh_token;
	}

	public String getScope() {
		return scope;
	}

	public void setScope(String scope) {
		this.scope = scope;
	}

	public Date getCreate_time() {
		return create_time;
	}

	public void setCreate_time(Date create_time) {
		this.create_time = create_time;
	}

	@Override
	public String toString() {
		return "ITNToken [token_type=" + token_type + ", user_token="
				+ access_token + ", expires_in=" + expires_in
				+ ", refresh_token=" + refresh_token + ", scope=" + scope + "]";
	}
}
